package cn.itwangxiang.android;

import android.app.TabActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.Toast;

/**
 * 程序UI主类
 * 
 * @author itwangxiang
 * 
 */
@SuppressWarnings("deprecation")
public class AppMain extends TabActivity {
	
	private Button tab0_button1;
	
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		initView();
	}

	public void initView() {
		TabHost tabHost = getTabHost();
		
		LayoutInflater.from(this).inflate(R.layout.main, tabHost.getTabContentView(), true);   
		
		tabHost.addTab(tabHost
				.newTabSpec("0")
				.setIndicator("实例")
				.setContent(R.id.tab1));
		tabHost.addTab(tabHost
				.newTabSpec("1")
				.setIndicator("代码")
				.setContent(R.id.tab2));
		tabHost.addTab(tabHost
				.newTabSpec("2")
				.setIndicator("学习")
				.setContent(R.id.tab3));
		
		tabHost.setOnTabChangedListener(new OnTabChangeListener() {
			
			@Override
			public void onTabChanged(String arg0) {
				// TODO Auto-generated method stub
				Toast.makeText(AppMain.this, "Cur Tab: "+arg0, Toast.LENGTH_SHORT).show();
			}
		});
		
		//将TabHost的Tab1设置为默认项
		tabHost.setCurrentTab(0);
		
		tab0_button1 = (Button) findViewById(R.id.button1);
		
	}
}
